package com.example;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;


@Aspect
public class MyClass {


    private static final String POINTCUT_METHOD =
            "execution(@com.example.TraceAspect * *(..))";

    private static final String POINTCUT_CONSTRUCTOR =
            "execution(@com.example.TraceAspect *.new(..))";


    @Pointcut(POINTCUT_METHOD)
    public void methodAnnotatedWithDebugTrace() {}

    @Pointcut(POINTCUT_CONSTRUCTOR)
    public void constructorAnnotatedDebugTrace() {}


    @Around("methodAnnotatedWithDebugTrace() || constructorAnnotatedDebugTrace()")
    public Object aronudWeaverPoint(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("method befer");
        Object result = joinPoint.proceed();
        return  result;
    }
}
